package com.ktjiaoyu.crm.config;

import com.ktjiaoyu.crm.interceptor.AuthorizationInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName : InterceptorConfig
 * @Description :
 * @Author : Lzz
 * @Date: 2023/11/22 09:30:37
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {


    /**
     * 配置拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] pathPatterns = {"/**"}; //拦截路径规则
        String[] excludePathPatterns = {"/","/login","/logout","/toLogin","/css/**","/fonts/**","/images/**","/js/**","/localcss/**","/localjs/**"};
        registry.addInterceptor(new AuthorizationInterceptor()) //注册拦截器
                .addPathPatterns(pathPatterns) //添加路径规则
                .excludePathPatterns(excludePathPatterns); //添加排除路径规则

    }

}
